package com.dennytech.tac.model;

import java.util.Date;

import android.os.Parcel;
import android.os.Parcelable;

import com.dennytech.tac.utils.CFUtils;

public class Record extends CFObject implements Parcelable {

	int id;
	String image;
	String intro;
	String dateStr;
	Date date;

	public Record() {
	}

	public Record(Parcel in) {
		id = in.readInt();
		image = in.readString();
		intro = in.readString();
		dateStr = in.readString();
		date = getDate();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}

	public String getDateStr() {
		return dateStr;
	}

	public void setDateStr(String date) {
		this.dateStr = date;
		this.date = CFUtils.StringToDate(date, "yyyyMMddHHmmss");
	}

	public void setDateStr(Date date) {
		this.dateStr = CFUtils.dateToString(date, "yyyyMMddHHmmss");
		this.date = date;
	}

	public Date getDate() {
		if (this.date == null) {
			this.date = CFUtils.StringToDate(this.dateStr, "yyyyMMddHHmmss");
		}
		return date;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(id);
		dest.writeString(image);
		dest.writeString(intro);
		dest.writeString(dateStr);
	}

	public static final Parcelable.Creator<Record> CREATOR = new Parcelable.Creator<Record>() {
		public Record createFromParcel(Parcel in) {
			return new Record(in);
		}

		public Record[] newArray(int size) {
			return new Record[size];
		}
	};

}
